import { getChannelsAPI } from '../../api/channel';
import { CHANNEL_SAVE_LIST, CHANNEL_UPDATE_CURRENT } from './actionType';

export const getChannelsActionCreator = () => {
  return async (dispatch) => {
    const res = await getChannelsAPI();
    dispatch({
      type: CHANNEL_SAVE_LIST,
      payload: res.data.channels,
    });
  };
};

export const updateCurrentAction = (id) => {
  return {
    type: CHANNEL_UPDATE_CURRENT,
    payload: id,
  };
};
